abstract class Shape{
    public double area1;
    public double area2;
    public double area3;
    public abstract void draw();
    public abstract void calArea();
}
//计算矩形的面积
class Rect extends Shape{
    private double width;
    private double length;
    //public double area;
    Rect(double width,double length){
        this.length = length;
        this.width = width;
    }
    @Override
    public void draw() {
        System.out.println("矩形 : length="+length+"width="+width);
    }

    @Override
    public void calArea() {
        area1 = length * width;
        System.out.println("矩形的面积 :"+area1);
    }
}

//计算圆的面积
class Cycle extends Shape{
     private double r;
     final private static double PI = 3.14;

    public Cycle(double r) {
        this.r = r;
    }

    @Override
    public void draw() {
        System.out.println("圆 : r="+r);
    }
    public void calArea(){
        area2 = PI * r * r;
        System.out.println("圆的面积 :"+area2);
    }
}
//计算三角形的面积
 class Triangle extends Shape{
    public double a;
    public double b;
    public double c;

    public Triangle(double a, double b,double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    @Override
    public void draw() {
        System.out.println("三角形 :a="+a+" "+"b="+b+" "+"c="+c);
    }
    public void calArea(){
        area3 = (a+b)/2;
        System.out.println("三角形的面积 :"+area3);
    }
}
public class Test {
    public static void drawMap(Shape shape){
        shape.draw();
        shape.calArea();
    }
    public static void main(String[] args) {
        Rect rect = new Rect(3,4);
        Cycle cycle = new Cycle(2.0);
        Triangle triangle = new Triangle(2,3,5) ;
        drawMap(rect);
        drawMap(cycle);
        drawMap(triangle);
    }
}
